#include <iostream>
#include <string>

using namespace std;

template<typename T>
auto tfunc(int a, double b, T Func) -> decltype(Func(a,b))  //返回类型只有实例化时才能知晓
{
    return Func(a,b);
}

auto func1(int a, double b) -> decltype(a+b)     //需要根据参数类型推导
{
    return a+b;
}

auto func2(int a,double b) -> string            //尾置返回string
{
    string ret;
    for(auto i = 0;i < a; ++i)
    {
        ret += to_string(b);
    }
    return ret;
}

auto main() -> int
{
    cout<<tfunc(2,3.5,func1)<<endl;
    cout<<tfunc(2,3.5,func2)<<endl;
}